<?php
require_once 'modules/content/models/Content.php';
class sidebarSticker extends Nine_Sticker
{
	public function run()
	{
		$user = Nine_Registry::getLoggedInUser();
		if (null != $user) {
			$user = $user->toArray();
			if (2 == $user['group_id']) {
//				$this->view->managerUrl = Nine_Registry::getAppBaseUrl()."merchant";
				$this->view->profileUrl = Nine_Registry::getAppBaseUrl()."merchant/profile/view";
			}
			else if( 3 == $user['group_id']) {
//				$this->view->managerUrl = Nine_Registry::getAppBaseUrl()."consumer";
				$this->view->profileUrl = Nine_Registry::getAppBaseUrl()."consumer/profile/view";
			}
		}
		else {
			$user = false;
		}	
		$this->view->user = $user;
		$this->view->managerUrl = Nine_Route::_(Nine_Registry::getAppBaseUrl() . "transaction/index/manage");
		/**
		 * Register link
		 */
		$this->view->registerUrl = Nine_Route::_(Nine_Registry::getAppBaseUrl()."content/index/detail/id/1");
		
		$objContent = new Models_Content();
		
		$allNews = $objContent->getAllEnabledContentByCategory(5,array(),array('sorting ASC'),5,0);
		
		foreach ($allNews as &$news) {
			$news['title'] = Nine_Function::subStringAtBlank($news['title'],80);
		}
		unset($news);
		
		$this->view->allNews = $allNews;
		
	}
}